<?php

$GET = $GLOBALS['MYT']->db_array("SELECT 
            cvu_ID
    FROM corresponsales
            LEFT OUTER JOIN csh_moviments ON cvu_OpType = CorrCashier
    WHERE cvu_Type = 5
                            AND cvu_User = {$_SESSION[$SESSID]}
                            AND cvu_Office = {$_SESSION[$SESSCD]}
                            AND cvu_Status = 1
                            AND cvu_Currency = {$_POST['FraMonCobro']}
                            AND DATE(cvu_Time) = DATE('{$sysTime}')
                            AND CorrNumero = {$_POST['FraCorresponsal']}");
if (isset($GET[1]['cvu_ID'])) {
    $GLOBALS['MYT']->db_query("UPDATE csh_moviments
						SET cvu_Amount = cvu_Amount+{$_POST['FraProm']}
						WHERE cvu_ID = {$GET[1]['cvu_ID']}");
} else {
    $GETCASHIER = $GLOBALS['MYT']->db_array("SELECT CorrCashier FROM corresponsales WHERE CorrNumero = {$_POST['FraCorresponsal']}");
    $GLOBALS['MYT']->db_query("INSERT INTO csh_moviments
			(cvu_Type, cvu_User, cvu_Office, cvu_Time, cvu_Status, cvu_POOL, cvu_Amount, cvu_OpType, cvu_Currency, cvu_Deposit) VALUES (5,{$_SESSION[$SESSID]},{$_SESSION[$SESSCD]},'{$sysTime}',1,0,{$_POST['FraProm']},{$GETCASHIER[1]['CorrCashier']},{$_POST['FraMonCobro']},0)");
}